﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ProgramMain.OpticNet
{
    public partial class FrmCableTunnelDistanceEdit : ProgramMain.Framework.frmBase
    {
        public FrmCableTunnelDistanceEdit()
        {
            InitializeComponent();
            cableTunnelDistanceList1.RedirectButtonImage = Properties.Resources.rewind_16;
            cableTunnelDistanceList2.RedirectButtonImage = Properties.Resources.fast_forward_16;
        }
        new public int? DetailID
        {
            set
            {
                cableTunnelDistanceEdit.DetailID = value;
                cableTunnelDistanceList1.HiddenCableTunnelID = value;
                cableTunnelDistanceList2.HiddenCableTunnelID = value;
            }
        }

        private void cableTunnelDistanceEdit_ReLoadVertex1(object sender, Framework.IntEvent e)
        {   
            
            if (cableTunnelDistanceList1.DetailID != e.ObjectID)
                cableTunnelDistanceList1.DetailID = e.ObjectID;
            else cableTunnelDistanceList1.DBRead();
        }

        private void cableTunnelDistanceEdit_ReLoadVertex2(object sender, Framework.IntEvent e)
        {
          
            if (cableTunnelDistanceList2.DetailID != e.ObjectID)
                cableTunnelDistanceList2.DetailID = e.ObjectID;
            else cableTunnelDistanceList2.DBRead();

        }

        private void cableTunnelDistanceList1_CableTunnelRedirect(object sender, Framework.IntEvent e)
        {
            if (!cableTunnelDistanceEdit.SaveRedirect()) return;
            DetailID = e.ObjectID;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            cableTunnelDistanceEdit.SaveCoordinate();
            DialogResult = DialogResult.OK;
        }

        private void cableTunnelDistanceEdit_CoordinateChanged(object sender, CableTunnelDistanceEdit.CoordinateChange e)
        {
            cableTunnelDistanceList1.CalcLen(e.OldCoordinate,e.NewCoordinate);
            cableTunnelDistanceList2.CalcLen(e.OldCoordinate, e.NewCoordinate);
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            cableTunnelDistanceEdit.SaveCoordinate();
        }
    }
}